<?
session_start();
header("Location:inbox.php");

include('./../config/db_settings.php');
include('pms_inc.php');

$user = $_SESSION[$settings['session_prefix'].'user_id'];
//Are they logged in or not?
if(!$user)
{
}
else
{
    //check the msg_id variable from the URL.
    $msg_id = $_REQUEST['msg_id'];
    if($msg_id>0)
    {
        //Delete the PM
        mysql_query("DELETE FROM ".$db_settings['messages_table']." WHERE id='$msg_id' AND receiver_id='$user'");
    }
    else
    {
        //A foreach loop for each pm in the array, get the values and set it as $pm_id because they were the ones selected for deletion
        foreach($_POST['pms'] as $num => $pm_id)
        	{
        	//Delete the PM
        	mysql_query("DELETE FROM ".$db_settings['messages_table']." WHERE id='$pm_id' AND receiver_id='$user'");
        	
        	}
    }
}
?> 